<?php

// 4/11/2010: immanuel192 write this action to show verse edit page

if (!defined('EXPONENT')) exit('');
global $db;

$song = null; $song_id=-1;
if (isset($_REQUEST['id'])) {
	$_REQUEST['id']=intval($_REQUEST['id']); $song_id = $_REQUEST['id'];
	// get song and collection object
	$sql="SELECT {$db->prefix}present_songs.*, {$db->prefix}present_song_collection.name collection_name, {$db->prefix}present_song_collection.id collection_id
		  FROM {$db->prefix}present_songs INNER JOIN {$db->prefix}present_song_collection
			   ON {$db->prefix}present_songs.collection_id = {$db->prefix}present_song_collection.id
		  WHERE {$db->prefix}present_songs.id = {$song_id}
		  LIMIT 0,1";
	$song = $db->selectObjectsBySql($sql);
	// get first object
	if ($song)
		$song=$song[0];
}
if ($song_id==-1)
	die("Wrong song collection value.");
	
	// get all song verse
	$verse = $db->selectObjects("present_song_verse","song_id = " . $song_id);
	foreach ($verse as $key=>$value)
	{
		// for background
		if ($value->background <= 0) {
			$value->picpath = '';
		} else {
			$file = $db->selectObject('file', 'id='.$value->background);
			$value->picpath = $file->directory.'/'.$file->filename;
		}
		// clear html format in-order to be shown well
		$value->content=strip_tags($value->content);
		$verse[$key]=$value;
	}
	$template = new template('slidemodule','_view_song');
	$template->assign('song',$song);
	$template->assign('verse',$verse);
	$template->register_permissions(slidemodule::permissions("",1),$loc);
	$template->output();

?>
